# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=lame

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.99.5
pkgrel=2
pkgdesc="A high quality MPEG Audio Layer III (MP3) encoder (mingw-w64)"
arch=('any')
url="http://www.opus-codec.org/"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config" "${MINGW_PACKAGE_PREFIX}-ncurses" "nasm")
depends=("${MINGW_PACKAGE_PREFIX}-libiconv")
options=('strip' 'staticlibs')
source=("http://downloads.sourceforge.net/${_realname}/${_realname}-${pkgver}.tar.gz"
    0001-fix-cr-for-awk-in-configure.mingw.patch)
md5sums=('84835b313d4a8b68f5349816d33e07ce'
         '629d7bf75acfcd57b4a648b8ad7e264e')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/0001-fix-cr-for-awk-in-configure.mingw.patch
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-nasm \
    --enable-shared
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
